package com.prs.crm.dao.oa.impl;

import java.util.Collection;
import java.util.Date;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.oa.SynodDao;
import com.prs.crm.domain.hr.Person;
import com.prs.crm.domain.oa.Synod;

public class SynodDaoImpl extends BaseDaoImpl<Synod> implements SynodDao{

	@Override
	public Collection<Synod> getSynod(Person person, Date date) {
		// TODO Auto-generated method stub
		Criteria criteria = this.getSession().createCriteria(Synod.class);
		criteria.add(Restrictions.le("beginTime", date));
		criteria.add(Restrictions.ge("endTime", date));
		criteria.createAlias("joinPersons", "p");
		criteria.add(Restrictions.eq("p.id", person.getId()));
		return criteria.list();
	}

}
